<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <!--优先使用IE最新版本和Chrome-->
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chome=1" />
    <!--视口--设备宽度--初始缩放比例--最小缩放比例--最大缩放比例--用户缩放-->
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <!--禁止浏览器自动的识别-电话号码-email--->
    <meta name="format-detection" content="telephone=no,email=no"/>
    <!--是否启用Web全屏-->
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-status-bar-style" content="normal|black|black-translucent">
    <!--设置苹果工具栏颜色-->
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <link rel="stylesheet" href="../sass/login.css">
    <title>Title</title>
</head>
<body>
<header>
    <a href="" class="a1">淘宝账户登录</a>
</header>

<section>
    <img src="../img/login/logo.png" height="66" width="230"/>
</section>

<div id="section-div1">
    账户：<input type="text" placeholder="手机号/邮箱/会员号" class="telephone">
    <br>
    密码：<input type="text" placeholder="请输入密码" class="password">
</div>
<br>
<div id="section-div2">
    <input type="button" value="登录" class="login" id="login">
</div>

<div id="section-div3">
    <a href="../html/sign.html">免费注册</a>
    <a href="">忘记密码</a>
</div>

<!--<div class="notLogin" id="notLogin">-->
    <!--<div class="reminder" id="reminder">-->
        <!--<p>您输入的密码不正确</p>-->
        <!--<button id="btn">-->
            <!--确定-->
        <!--</button>-->
    <!--</div>-->
<!--</div>-->

</body>
<script src="../js/zishiying.js"></script>
<script src="../js/jquery.min.js"></script>
<!--<script src="../js/login.js"></script>-->
</html>
<script>

    var tRet = /^1\d{10}$/;
    var pRet = /^\d{5,17}$/;


    $(".telephone").keyup(function() {
        var str = $(".telephone").val();
    })


    $(".password").keyup(function() {
        var str = $(".password").val();
        if(pRet.test(str)) {
            $(".login").css("background", "orangered");
        }
    })
    if(localStorage.getItem("user_phone")) {
        $(".telephone").val(localStorage.getItem("user_phone"));
    }

    $(".login").on('click', function() {
			console.log("in")
        //ajax 请求
        $.ajax({
            type: "post",
            url: "http://47.92.37.168/supermarket/data/login.php",
            async: true,
            data: {
                user_phone: $(".telephone").val(),
                user_pass_word: $(".password").val(),
            },
            dataType: "jsonp",
            jsonp: "callback",
            success: function(data) {
                console.log(data);
                if(data.msg == "success") {
                    localStorage.setItem("user_phone", $(".telephone").val());
                    localStorage.setItem("user_addr", data.info.user_addr);
                    setTimeout(function() {
                        location.href = "../index.html";
                    }, 500)
                } else if(data.msg == "error") {
                    alert("用户名或者密码输入有误")
                }
            }
        })
    })
</script>